package bookstore;

import java.util.Scanner;

public class Person {
    private String name;
    private double sum=0;

    public void setSum(double sum) {
        this.sum = sum;
    }

    public double getSum() {
        return sum;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Person(String name) {
        super();
        this.name = name;
    }
    public Book buybook1(Book[] book) {
        Book book2=null;

        Scanner y=new Scanner(System.in);
        for (int i = 0; i <book.length ; i++) {
            System.out.print("请输入购买的图书编号输入0结束");
            int id = y.nextInt();

            if (id==0){
                break; }
            else {
                for (int l = 0; l < book.length; l++) {
                    if (book[l].getId() == id) {
                        book2 = book[l];
                        break;
                    }


                }
            }
            System.out.println("请输入购买书的数量");
            int a=y.nextInt();

            sum=a*book2.getPrice()+sum;

        }
        return book2;





    }
}
